﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Hisun.Models;
using Hisun.Controllers;

namespace Hisun.View.Setup
{
    public partial class Scrb_Setup_DayLimit : System.Web.UI.Page
    {
        HisunDBDataContext db = new HisunDBDataContext();
        public string alert;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var MyDayLimit = (from a in db.TSCRB_DM_BasicInfoItems
                                 where a.项目编码 == "maxday"
                                 select a).Single();

               string MyMaxDay = MyDayLimit.项目值;
               DropDownList_DayLimit.SelectedValue = MyMaxDay; 
            }
        }

        protected void Button_Save_Click(object sender, EventArgs e)
        {
            var MyEidtRow = (from a in db.TSCRB_DM_BasicInfoItems
                             where a.项目编码 == "maxday"
                             select a).Single();

            MyEidtRow.项目值 = DropDownList_DayLimit.SelectedValue;


            try
            {
                db.SubmitChanges();
                alert = "<script>alert('保存成功');</script>";
            }
            catch
            {

                alert = "<script>alert('保存失败');</script>";
            }
        
        }
    }
}
